#include  <cstdio>
#include  <stack>
#include  <algorithm>
#include  <cstring>
#include  <vector>
#include  <iostream>
using namespace std;

stack<int> a,b;
vector<int> ops;
int f[220],t[220],counter = 0,n;
const char *op[4] = {"push 1","push 2","pop 1","pop 2"};

bool dfs(int i,int j)
{
	if( j == n)
		return true;

	if( i>= 0 && f[i] == t[j])
	{
		ops.push_back(0);
		ops.push_back(2);
		i--;
		if(dfs(i,++j))
			return true;
		else
		{
			ops.erase(ops.end()-1);
			ops.erase(ops.end()-1);
			return false;
		}
	}
	else if( !a.empty() && a.top() == t[j])
	{
		ops.push_back(2);
		int temp = a.top();
		a.pop();
		if( dfs(i,++j) )
			return true;
		else
		{
			a.push(temp);
			ops.erase(ops.end()-1);
			return false;
		}
	}
	else if( !b.empty() && b.top() == t[j])
	{
		ops.push_back(3);
		int temp = b.top();
		b.pop();
		if( dfs(i,++j) )
			return true;
		else
		{
			b.push(temp);
			ops.erase(ops.end()-1);
			return false;
		}
	}
	else if( i >= 0 && (a.empty() || f[i] <= a.top()) )
	{
		ops.push_back(0);
		a.push(f[i--]);
		if( dfs(i,j) )
			return true;
		i++;
		a.pop();
		ops.erase(ops.end()-1);
	}
	if( i >= 0 && (b.empty() || f[i] <= b.top()) )
	{
		ops.push_back(1);
		b.push(f[i--]);
		if( dfs(i,j) )
			return true;
		else
		{
			b.pop();
			ops.erase(ops.end()-1);
			return false;
		}
	}
	return false;
}

int main(int argc, char *argv[])
{
	while( scanf("%d",&n) && n != 0 )
	{
		bool can = true;
		ops.clear();
		memset(f,0,880);
		memset(t,0,880);
		for(int c = 0; c < n ; ++c)
		{
			scanf("%d",&f[c]);
			t[c] = f[c];
		}
		printf("#%d\n",++counter);
		sort(t,t+n);
		int i = n-1;
		int j = 0;
		
		if(dfs(i,j))
			for( int i = 0; i < ops.size() ; ++i )
				printf("%s\n",op[ops[i]]);
		else
			printf("impossible\n");
	}
}
